import { RouterMount, createRouter } from 'uni-simple-router';
const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,
	routes: [...ROUTES]
});

// 全局路由前置守卫
router.beforeEach((to, from, next) => {
	// console.log(to);  
	if(to.meta.auth) {
		console.log('需要登录');
		// 获取全局token
		if ('token') {
			next();
		} else {
			console.log('请登录');
		}
	} else {
		console.log('不需要登录');
		next();
	}
});

// 全局路由后置守卫
router.afterEach((to,from) => {
	console.log('跳转结束！');
});

export {
	router,
	RouterMount
};
